home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Splitmail_JoinMail / splitmail < prev   
Encoding:
Text File  |  1994-03-04  |  1.4 KB  |  48 lines

  1. #!/bin/sh
  2. #############################################################################
  3. #
  4. # Program: splitmail
  5. # Usage: splitmail directory mailaddress
  6. # Example: splitmail /LocalApps jasmerb@ohsu.edu
  7. #
  8. # Misc: you can use any pathname (doesn't have to be a full pathname), but
  9. #       you might want to avoid using '.' and '..' for the directory as you
  10. #       will send the file '..tar.Z' or '...tar.Z' which is kind of screwy.
  11. #
  12. # you can alter the size of each piece of mail with the split -<N> flag
  13. #    1500 is about 90K, 4000 would be about 240K, etc.
  14. #############################################################################
  15.  
  16. SPLITDIR=/tmp/splitmaildir$$
  17. DIRNAME=`basename $1`
  18. UUFILE=
  19.  
  20. if [ $# != 2 ] ; then
  21.     echo "usage: splitmail directory mailaddress"
  22.     exit 1
  23. else
  24.     if [ -d $1 ] ; then
  25.         ZFILE=/tmp/splitmail$$.gtar.Z
  26.         UUFILE=$ZFILE.uu
  27.         echo "gnutar cf - $DIRNAME | compress -c | uuencode $ZFILE > $UUFILE"
  28.         gnutar cf - $DIRNAME | compress -c | uuencode $ZFILE > $UUFILE
  29.     else
  30.         ZFILE=/tmp/splitmail$$.Z
  31.         UUFILE=$ZFILE.uu
  32.         echo "compress -c $DIRNAME | uuencode $ZFILE > $UUFILE"
  33.         compress -c $DIRNAME | uuencode $ZFILE > $UUFILE
  34.     fi
  35.     mkdirs $SPLITDIR
  36.     cd $SPLITDIR
  37.     echo "splitting"
  38.     split -1500 ../`basename $UUFILE` $DIRNAME.
  39.     for i in *.??
  40.     do
  41.        echo "mailing $i"
  42.        /usr/ucb/mail -s "$i" $2 < $i
  43.     done
  44.     echo "cleaning up"
  45.     rm -rf $ZFILE $UUFILE $SPLITDIR
  46. fi
  47. exit 0
  48.